<?php
class Portfoliomanager_Model_Insertportfolioitem implements Portfoliomanager_Model_Mainable{
    
    private $core_controller_notnull;
    private $core_controller_tokencheckout;
    
    private $excepted_result = 1;
    
    private $portfoliomanager_data_insertportfolioitemsettings;
    private $portfoliomanager_data_insertportfolioitemmetavalues;
    private $portfoliomanager_data_insertportfolioitemcontentvalues;
    
    private $insert_portfolio_settings_result;
    private $insert_portfolio_meta_result;
    private $insert_portfolio_content_result;
    
    public function main(array $variables = null) {
        $this->core_controller_notnull = new Core_Controller_Notnull;
        $this->core_controller_notnull->main($variables);
        $this->core_controller_tokencheckout = new Core_Controller_Tokencheckout;
        $this->core_controller_tokencheckout->main($variables['post']);
        
        $this->portfoliomanager_data_insertportfolioitemsettings = new Portfoliomanager_Data_Insertportfolioitemsettings;
        $this->insert_portfolio_settings_result = $this->portfoliomanager_data_insertportfolioitemsettings->main($variables);
        $this->portfoliomanager_data_insertportfolioitemmetavalues = new Portfoliomanager_Data_Insertportfolioitemmetavalues;
        $this->insert_portfolio_meta_result = $this->portfoliomanager_data_insertportfolioitemmetavalues->main($variables);
        $this->portfoliomanager_data_insertportfolioitemcontentvalues = new Portfoliomanager_Data_Insertportfolioitemcontentvalue;
        $this->insert_portfolio_content_result = $this->portfoliomanager_data_insertportfolioitemcontentvalues->main($variables);
        
        if(
                ($this->insert_portfolio_settings_result == $this->excepted_result) &&
                ($this->insert_portfolio_meta_result == $this->excepted_result) &&
                ($this->insert_portfolio_content_result == $this->excepted_result)
                ){
            header("Location: ".SITE_ROOT."zarzadzaj-portfolio.html");
        }
        else {
            header("Location: ".SITE_ROOT."zarzadzaj-portfolio.html");
        }
    }

}
